﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTcms.Web.UI;
using DTcms.Common;
using System.Data;

namespace DTcms.Web.shareWeb
{
    public partial class xinxi_details : System.Web.UI.Page
    {
        public string[] xinxi = new string[8];
        protected int id = 0;
        string avatar = "/image/default_avatar.png";
        protected void Page_Load(object sender, EventArgs e)
        {
            id = DTRequest.GetQueryInt("xxid",0);
            if (!IsPostBack)
            {
                if (id > 0){
                    BLL.xinxi bll = new BLL.xinxi();
                    Model.xinxi model = bll.GetModel(id);
                    if (model != null)
                    {
                        xinxi[0] = "99";
                        xinxi[1] = Utils.DateStringFromNow(Convert.ToDateTime(model.add_time));
                        xinxi[2] = "尺寸：" + model.size_long + "×" + model.size_wide + "×" + model.size_height + "mm";
                        xinxi[3] = model.content.ToString();
                        if (model.user_id > 0)
                        {
                            Model.users userModel = new BLL.users().GetModel(model.user_id);
                            if (userModel != null)
                            {
                                xinxi[5] = userModel.user_name;
                                
                                if (string.IsNullOrWhiteSpace(userModel.avatar))
                                {
                                    avatar="/image/default_avatar.png";
                                }
                                else if (userModel.avatar.Contains("shicaiquanzi"))
                                {
                                    //strTxt.Append(",\"avatar\":\"http://" + userModel.avatar + "\"");
                                    if (userModel.avatar.Contains("http://"))
                                    {
                                        avatar = userModel.avatar;
                                       

                                    }
                                    else { avatar = "http://" + userModel.avatar; }
                                }
                                else
                                {
                                    avatar = "http://pic.shicaiquanzi.com" + userModel.avatar ;
                                   
                                }
                                xinxi[6] = avatar;

                                string imglist = "";
                                if (model.albums != null)
                                {
                                    foreach (Model.xinxi_albums modelt in model.albums)
                                    {
                                        if (!modelt.original_path.Contains("http://"))
                                        {
                                            imglist += "<div class=\"pic\"><img src=\"http://" + modelt.original_path + "\"/></div>";
                                        }
                                        else
                                        {
                                            imglist += "<div class=\"pic\"><img src=\"" + modelt.original_path + "\"/></div>";
                                        }
                                    }
                                }
                                if (!string.IsNullOrEmpty(imglist))
                                {
                                    xinxi[7] = imglist;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}